package com.zp.pattern.strategy;

public class Environment {
	//这是父类的引用，创建的对象可以将指向子类对象的引用赋给父类引用；
	private Strategy strategy;
	
	public Environment(Strategy strategy){
		this.strategy = strategy;
	}

	public Strategy getStrategy() {
		return strategy;
	}

	public void setStrategy(Strategy strategy) {
		this.strategy = strategy;
	}
	
	//父类引用指向子类对象，这里的strategy已经指向对应子类对象；
	public int caculate(int a,int b){
		return strategy.caculate(a,b);
	}
}
